﻿var helper = new Helper();
var measurementData;
var courseUnitData;
var expectKnowledgeTypeData;
var optionsCourseGrid = {
    editable: true,
    enableRowReordering: true,
    enableCellNavigation: true,
    asyncEditorLoading: false,
    autoEdit: false
};
var courseGrid; 


function getCourseColumn() {
    var columnGridDocument = [
                { id: "ID", name: "ID", field: "ID", width: 25, cssClass: "cell-title" },
                { id: "CourseName", name: "CourseName", field: "CourseName", width: 120 },
                { id: "CourseDetails", name: "CourseDetails", field: "CourseDetails", width: 120 },
                { id: "CourseLevel", name: "CourseLevel", field: "CourseLevel", minWidth: 60 },
                { id: "CourseVersion", name: "CourseVersion", field: "CourseVersion", minWidth: 60 },
        { id: "CourseTime", name: "CourseTime", field: "CourseTime", width: 40 },
        { id: "CourseTimeUnitID", name: "CourseTimeUnitID", width: 70, field: "CourseTimeUnitID", formatter: Slick.Formatters.CourseUnitFormatter, editor: Slick.Editors.CourseTimeUnitEditor },
        { id: "MeasurementID", name: "MeasurementID", field: "MeasurementID", width: 120, formatter: Slick.Formatters.MeasurementFormatter, editor: Slick.Editors.MeasurementSelect },
        { id: "ExpectKnowledgeValue", name: "ExpectKnowledgeValue", field: "ExpectKnowledgeValue", minWidth: 60 },
        { id: "ExpectKnowledgeTypeID", name: "ExpectKnowledgeTypeID", field: "ExpectKnowledgeTypeID", minWidth: 60 }
                //{ id: "Enter", name: "", field: "ID", formatter: Slick.Formatters.Enter }
            ];
    return columnGridDocument;
};


function bindCourse(datas, column, options) {
    courseGrid = new Slick.Grid("#grid", datas, column, options);
};
jQuery(document).ready(function () {
    jQuery("#grid").width(jQuery(window).width() -680);
    //$("#grid").height($window).height());
   
    helper.getMeasurementData(function (data) {
        measurementData = data;
    });
    helper.getCourseTimeUnitData(function (data) {
        courseUnitData = data;
    });
    helper.getExpectKnowledgeTypeData(function (data) {
        expectKnowledgeTypeData = data;
    });
    helper.getCourseData(function (data) {
        bindCourse(data, getCourseColumn(), optionsCourseGrid);
    });
});